const MovieHttp = require("../../utils/MovieHttp")
const { handleStar } = require("../../utils/Star")
Page({
  data: {
    
  },
  onLoad: async function () {
    var res = await MovieHttp.getTop250()
    var top = res.data.res
    var movie = []
    top.forEach(item => {
      var { title, pic, rating, _id } = item;
      var star = rating
      console.log(item.rating)
      movie.push({
        title,
        pic,
        rating,
        _id,
        star: handleStar(star)
      })
    })
    console.log(movie)
    this.setData({
      movie
    })
  },
  handleClick(event) {
    console.log(event.currentTarget.dataset)
    var { aid } = event.currentTarget.dataset
    wx.navigateTo({
      url: `/pages/detailtop/detailtop?id=${aid}`
    })
  }
})